package com.leiy.webmagic.test;


import org.junit.Test;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

public class JobProcessor implements PageProcessor {

    private Site site = Site.me();

    // 解析页面
    @Override
    public void process(Page page) {
        page.putField("div",page.getHtml().css("div.dt a").all());
    }

    @Override
    public Site getSite() {
        return site;
    }

    @Test
    public void testFirst(){
        Spider.create(new JobProcessor())
                .addUrl("https://kuaibao.jd.com")
                .run();
    }
}
